#define _CRT_SECURE_NO_WARNINGS 1


#include<stack>
#include<iostream>

using namespace std;

int main()
{
    int num = 0;
    stack<int> st;
    int count = 0;
    while (cin >> num)
    {
        if (st.empty())
        {
            st.push(num);
            continue;
        }
        if (st.top() > num)
        {
            count++;
        }
        st.push(num);
        if (count >= 2)
        {
            cout << 0 << endl;
            return 0;
        }
    }
    cout << 1 << endl;

    return 0;
}